import 'package:xlsk/api/index.dart';
import 'package:xlsk/config/index.dart';

class StudentApi {
  factory StudentApi(){
    final _instance = StudentApi._();
    return _instance;
  }
  StudentApi._();

  getStudent(context,path,data) async{
    var result = [];
    var res = await Request(context).post(path,data);
    var code = res['code'] is String?num.parse(res['code']):res['code'];
    if(code == 200){
      result = res['data'];
    }
    return result;
  }

  getStudentView(context,data) async{
    var result = {};
    var res = await Request(context).post('/student/view',data);
    var code = res['code'] is String?num.parse(res['code']):res['code'];
    if(code == 200){
      result = res['data'];
      result['headimg'] = '${Config().baseUrl}${result['headimg']}';
    }
    return result;
  }

  getKecheng(context,data) async{
    var result = [];
    var res = await Request(context).post('/student/kecheng',data);
    var code = res['code'] is String?num.parse(res['code']):res['code'];
    if(code == 200){
      result = res['data'];
    }
    return result;
  }
}